package com.ruirenyun.util.common;

import java.util.Comparator;
import java.util.Map;

public class ListComparator implements Comparator {
    //对于比较哪个列
    private String comparedProperty;

    public ListComparator(String comparedProperty) {
        this.comparedProperty = comparedProperty;
    }

    @Override
    public int compare(Object o1, Object o2) {
        Map<String, Object> map1 = (Map<String, Object>) o1;
        Map<String, Object> map2 = (Map<String, Object>) o2;
        String value1 = String.valueOf(map1.get(comparedProperty));
        String value2 = String.valueOf(map2.get(comparedProperty));

        return value1.compareTo(value2)/*等于*/;
    }
}
